<template>
   <el-card class="box-card">
    <div slot="header" class="clearfix">
    <h1 class="container-title fl">公司信息</h1>
    </div>
    <!-- 在这里写数据 -->
    <el-card class="box-card-min">
    <div slot="header" class="clearfix">
        <!-- 邮箱 -->
  <el-form status-icon   label-width="80px" class="demo-ruleForm">
   <el-form-item label="公司名称">
    <el-input type="text" v-model="name" autocomplete="off" style="width:250px;"></el-input>
  </el-form-item>
  <el-form-item label="城市">
    <el-input type="text" v-model="city" autocomplete="off" style="width:250px;"></el-input>
  </el-form-item>
  <el-form-item label="街道">
    <el-input type="text" v-model="street" autocomplete="off" style="width:250px;"></el-input>
  </el-form-item>
  <el-form-item label="公司logo">
    <input @change="upload_qiniu" type="file">
  </el-form-item>
  <el-form-item>
   <div class="block">
    <el-image :src="src" style="width:200px;height:100px"></el-image>
  </div>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="addcommpany" style="width:250px;">保存</el-button>
  </el-form-item>
</el-form>
</div>
</el-card>
</el-card>
       
    </template>
    
    <script>
      import {adduser,com,qn} from '../api/api'
    
        export default {
    
            data(){
                return {
                    msg:'你好，这里是首页',
                    name:'',
                    city:'',
                    street:'',
                    logo:'',
                    src:'',
                    uptoken:'',
                        
                }
            },
            //定义组建标签
            components:{
            },
            filters: {
     
　　},
            //自定义方法
            methods:{
              upload_qiniu:function(e){
      console.log(this.uptoken)
      let file=e.target.files[0]
      let param = new FormData();
      //将上传凭证添加参数
      param.append('token',this.uptoken)
      //附加文件
      param.append('file',file)
      const axios_qiniu=this.axios.create({withCredentials: false});
      //发送请求
      axios_qiniu({
        method:'POST',
        url:'http://up-z1.qiniu.com/',
        data:param,
        timeout:30000

      }).then(res =>{

        this.src='http://q9wdlon8p.bkt.clouddn.com/'+res.data.key;
    
      })

    },
               get_token(){
                qn().then( res => {
                  this.uptoken=res.uptoken
         
              })
    
          },
          
          addcommpany:function(){
       // 以上为对数据的验证
        var data={'username':this.username,'password':this.password,'email':this.email,'phone':this.phone,'role_id':this.role_id}
        adduser(data).then( res => {
           if(res.code==200){
            this.$Message(res.message)
            
           }else {
             this.$Message(res.message)
           }
         
        })
                }
    
            },
            //钩子方法
            mounted:function(){
              this.get_token()
              
              var params={'username':localStorage.getItem('username')}
               com(params).then(res=>{
                  this.name=res.name
                  this.city=res.city
                  this.street=res.street
                  this.src=res.img
      
       
                    

                })
    
            },
            //监听属性
            watch:{
    
    
            },
            //计算属性
            computed:{
    
    
            }
    
    
    
        }
    
    
    </script>
    
    <style>
 .box-card-min{
    height:450px;
    width:450px;
 
    margin:0 auto;
    margin-top:30px;
    
 }
  .box-card{
        
         height:650px;

    }
    
  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }
  .clearfix:after {
    clear: both
  }
  .container-title {
    font-size: 20px;
    line-height: 32px;
    font-weight: normal;
    color: #39486c;
  }
  .fl {
    float: left;
  }
  .inp-box {
    font-size: 16px;
    line-height: 32px;
    margin-left: 30px;
}
 
 
  .login_title {
    margin: 0px auto 40px auto;
    text-align: center;
    color: #505458;
  }
    </style>